home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / VIS082S.ARJ / FOSSIL.PAS < prev    next >
Pascal/Delphi Source File  |  1991-03-24  |  15KB  |  472 lines

  1.  
  2. (*    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  3.       █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
  4.       █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
  5.       █░░░░░░░█████████████████████████████████████████████░░░░░░░░░░░░░█
  6.       █░░░░░░░██                                         ██ ░░░░░░░░░░░░█
  7.       █░░░░░░░██ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██ ░░░░░░░░░░░░█
  8.       █░░░░░░░██ ░░░░░░░██████░░░░███████░░░███████░░██░░██ ░░░░░░░░░░░░█
  9.       █░░░░░░░███████░░█      █░░░█       ░░█       ░██ ░██ ░░░░░░░░░░░░█
  10.       █░░░░░░░██      ░█ ░░░░░█ ░░███████ ░░███████ ░██ ░██ ░░░░░░░░░░░░█
  11.       █░░░░░░░██ ░░░░░░█ ░░░░░█ ░░░     █ ░░░     █ ░██ ░██ ░░░░░░░░░░░░█
  12.       █░░░░░░░██ ░░░░░░░██████  ░░███████ ░░███████ ░██ ░████████░░░░░░░█
  13.       █░░░░░░░░  ░░░░░░░░      ░░░░       ░░░       ░░  ░         ░░░░░░█
  14.       █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
  15.       █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
  16.       ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  17.    ■  FIDO/OPUS/SEADOG/Standard Interface Layer  ■           Version 1.02
  18.  
  19.       Interface for X00 and BNU Fossil Driver(s)
  20.  
  21.       Written by: Mike Whitaker  *)
  22.  
  23. {$R-,S-,I-,D-,F+,V-,B-,N-}
  24.  
  25. Unit Fossil;
  26.  
  27. Interface
  28.  
  29. Uses Dos, Crt;
  30.  
  31. Const  CTS_RTS  = 2;    { To Control Flow Control }
  32.        XON_XOFF = 9;
  33.  
  34. Type Fossil_Struct = Record
  35.        StructSize : Word;
  36.        MajorVer   : Byte;
  37.        MinVer     : Byte;
  38.        FOS_ID     : Array [1..2] of Word;
  39.        Inp_Buffer : Word;
  40.        Recv_Bytes : Word;
  41.        Out_Buffer : Word;
  42.        Send_Bytes : Word;
  43.        SWidth     : Byte;
  44.        SHeight    : Byte;
  45.        BaudRate   : Byte
  46.      End;
  47.  
  48. Var FosPort  : Byte;
  49.  
  50.  
  51. Function  Install_Fossil (ComPort:Byte):Boolean;
  52. Procedure Close_Fossil (ComPort:Byte);
  53. Procedure Set_Fossil (ComPort:Byte; BaudRate:LongInt; DataBits:Byte;
  54.                       Parity:Char; StopBits:Byte);
  55. Procedure SendChar (K:Char);
  56. Procedure SendString (S:String);
  57. Function  GetChar:Char;
  58. Function  Fossil_Chars:Boolean;
  59. Function  Fossil_Carrier:Boolean;
  60. Procedure Fossil_DTR (ComPort:Byte; State:Boolean);
  61. Procedure Hangup;
  62. Procedure Fossil_Timer (Var Tick_Int, Ints_Sec:Byte; MS_Tics:Integer);
  63. Procedure Fossil_OutPut_FLUSH (ComPort:Byte);
  64. Procedure Fossil_Nuke_Input   (ComPort:Byte);
  65. Procedure Fossil_Nuke_OutPut  (ComPort:Byte);
  66. Function  NoWait_Send (K:Char):Boolean;
  67. Function  Fossil_Peek:Char;
  68. Function  Fossil_GetChar:Char;
  69. Function  Fossil_Wait:Char;
  70. Procedure Fossil_FLOW (State:Byte);
  71. Procedure Set_CtrlC (ComPort, State:Byte);
  72. Function  CtrlC_Check (ComPort:Byte):Boolean;
  73. Procedure Fossil_GotoXY (X,Y:Byte);
  74. Procedure Fossil_Position (Var X,Y:Byte);
  75. Function  Fossil_WhereX:Byte;
  76. Function  Fossil_WhereY:Byte;
  77. Procedure ANSI_Write (K:Char);
  78. Procedure WatchDog (Status:Boolean);
  79. Procedure BIOS_Write (K:Char);
  80. Function  Add_Fossil_Proc    (Var P):Boolean;
  81. Function  Delete_Fossil_Proc (Var P):Boolean;
  82. Procedure WarmBoot;
  83. Procedure ColdBoot;
  84. Function  Fossil_BlockRead  (Bytes:Word; Var Buffer):Integer;
  85. Function  Fossil_BlockWrite (Bytes:Word; Var Buffer):Integer;
  86. Function  Fossil_Descrip (ComPort:Byte):String;
  87.  
  88. Implementation
  89.  
  90. {$L FOSSIL.OBJ}
  91.  
  92. Function  Install_Fossil (ComPort:Byte):Boolean;    External;
  93. Procedure Close_Fossil (ComPort:Byte);              External;
  94. Procedure SendChar (K:Char);                        External;
  95. Function  GetChar:Char;                             External;
  96. Function  Fossil_Chars:Boolean;                     External;
  97. Function  Fossil_Carrier:Boolean;                   External;
  98. Procedure Fossil_DTR (ComPort:Byte; State:Boolean); External;
  99. Procedure Fossil_Hangup;                            External;
  100. Procedure Fossil_Output_Flush (ComPort:Byte);       External;
  101. Procedure Fossil_Nuke_Input   (ComPort:Byte);       External;
  102. Procedure Fossil_Nuke_OutPut  (ComPort:Byte);       External;
  103. Function  NoWait_Send (K:Char):Boolean;             External;
  104. Function  Fossil_Peek:Char;                         External;
  105. Function  Fossil_GetChar:Char;                      External;
  106. Function  Fossil_Wait:Char;                         External;
  107. Procedure Fossil_FLOW (State:Byte);                 External;
  108. Procedure Set_CtrlC (ComPort, State:Byte);          External;
  109. Function  CtrlC_Check (ComPort:Byte):Boolean;       External;
  110. Procedure Fossil_GotoXY (X,Y:Byte);                 External;
  111. Procedure Fossil_Position (Var X,Y:Byte);           External;
  112. Function  Fossil_WhereX:Byte;                       External;
  113. Function  Fossil_WhereY:Byte;                       External;
  114. Procedure ANSI_Write (K:Char);                      External;
  115. Procedure WatchDog (Status:Boolean);                External;
  116. Procedure BIOS_Write (K:Char);                      External;
  117. Function  Add_Fossil_Proc    (Var P):Boolean;       External;
  118. Function  Delete_Fossil_Proc (Var P):Boolean;       External;
  119. Procedure WarmBoot;                                 External;
  120. Procedure ColdBoot;                                 External;
  121. Function  Fossil_BlockRead  (Bytes:Word; Var Buffer):Integer; External;
  122. Function  Fossil_BlockWrite (Bytes:Word; Var Buffer):Integer; External;
  123.  
  124.  
  125. Var R:Registers;
  126. (*
  127. Procedure Delay (I:Integer);
  128. Begin
  129.   R.Ah := $86;
  130.   Move (I,R.Cx,2);
  131.   Intr ($15,R)
  132. End;
  133.  
  134. Function Install_Fossil (ComPort:Byte):Boolean;
  135. Begin                                   { Initializes the Specified  }
  136.   R.Ah := $04;                          { Communications Port        }
  137.   R.Dx := ComPort - 1;                  { Sets FOSPORT to COMPORT    }
  138.   R.Bx := $4F50;
  139.   Intr ($14,R);
  140.   Install_Fossil := R.Ax = $1954;
  141.   FosPort := ComPort - 1
  142. End;
  143.  
  144. Procedure Close_Fossil (ComPort:Byte);  { Closes the Initialized     }
  145. Begin                                   { Communications Port        }
  146.   R.Ah := $05;
  147.   R.Dx := ComPort - 1;
  148.   Intr ($14,R);
  149.   FosPort := 255
  150. End;
  151. *)
  152.  
  153. Procedure Set_Fossil (ComPort:Byte; BaudRate:LongInt; DataBits:Byte;
  154.                       Parity:Char; StopBits:Byte);
  155. Var Baud,Code:Byte;                     { Sets the to the COMPORT    }
  156. Begin                                   { The BaudRate, DataBits,    }
  157.   Case BaudRate of                      { The Parity, And StopBits   }
  158.    1200  : Baud := 128;                 { Sets FOSPORT to COMPORT    }
  159.    2400  : Baud := 160;
  160.    4800  : Baud := 192;
  161.    9600  : Baud := 224;
  162.    19200 : Baud := 0
  163.    Else If BaudRate = 38400 Then Baud := 32
  164.   End;
  165.   Case DataBits of
  166.  { 5 : Baud := Baud + 0; }
  167.    6 : Baud := Baud + 1;
  168.    7 : Baud := Baud + 2;
  169.    8 : Baud := Baud + 3
  170.   End;
  171.   Case Parity of
  172.  { 'N' : Baud := Baud + 0; }
  173.    'O' : Baud := Baud + 8;
  174.    'E' : Baud := Baud + 24
  175.   End;
  176.   Case StopBits of
  177.    1 : Baud := Baud + 0;
  178.    2 : Baud := Baud + 4
  179.   End;
  180.   R.Ah := 0;
  181.   R.Al := Baud;
  182.   R.Dx := ComPort - 1;
  183.   Intr ($14,R);
  184.   FosPort := ComPort - 1
  185. End;
  186.  
  187. (*
  188. Procedure SendChar (K:Char);            { Transmitts a Character     }
  189. Begin                                   { through FOSPORT Comm Port  }
  190.   R.Ah := $01;                          { and then Waits.            }
  191.   R.Al := Ord(K);
  192.   R.Dx := FosPort;
  193.   Intr ($14,R)
  194. End;
  195. *)
  196.  
  197. Procedure SendString (S:String);        { Sends a String through the }
  198. Var I:Integer;
  199. Begin
  200.   I:=Fossil_BlockWrite (Length(S),S)
  201. End;
  202.  
  203. (*
  204. Function GetChar:Char;                  { Gets a Character from the  }
  205. Begin                                   { FOSPORT Communications Port}
  206.   R.Ah := $02;
  207.   R.Dx := FosPort;
  208.   Intr ($14,R);
  209.   GetChar := Chr(R.Al)
  210. End;
  211.  
  212. Function Fossil_Chars:Boolean;
  213. Begin
  214.   R.Ah := $03;
  215.   R.Dx := FosPort;
  216.   Intr ($14,R);
  217.   Fossil_Chars := (R.Ah And 1) = 1
  218. End;
  219.  
  220. Function Fossil_Carrier:Boolean;        { Detects whether a Carrier  }
  221. Begin                                   { is on FOSPORT Port         }
  222.   R.Ah := $03;
  223.   R.Dx := FosPort;
  224.   Intr ($14,R);
  225.   Fossil_Carrier := (R.Al And 128) = 128
  226. End;
  227.  
  228. Procedure Fossil_DTR (ComPort:Byte; State:Boolean);
  229. Begin                                   { Lowers/Raises the DTR on   }
  230.   R.Ah := $06;                          { COMPORT                    }
  231.   R.Al := Byte(State);
  232.   R.Dx := ComPort - 1;
  233.   Intr ($14,R)
  234. End;
  235. *)
  236.  
  237. Procedure Hangup;
  238. Begin
  239.   If Not Fossil_Carrier Then Exit;
  240.   Fossil_DTR (FosPort + 1,False);
  241.   Delay (700);
  242.   Fossil_DTR (FosPort + 1,True);
  243.   If Fossil_Carrier Then SendString ('+++')
  244. End;
  245.  
  246. Procedure Fossil_Timer (Var Tick_Int, Ints_Sec:Byte; MS_Tics:Integer);
  247. Begin
  248.   R.Ah := $07;
  249.   Intr ($14,R);
  250.   Tick_Int := R.Al;
  251.   Ints_Sec := R.Ah;
  252.   MS_Tics  := R.Dx
  253. End;
  254.  
  255. (*
  256. Procedure Fossil_OutPut_FLUSH (ComPort:Byte);
  257. Begin                                   { Forecs the OutPut Chars    }
  258.   R.Ah := $08;                          { out of the Buffer          }
  259.   R.Dx := ComPort - 1;
  260.   Intr ($14,R)
  261. End;
  262.  
  263. Procedure Fossil_Nuke_OutPut (ComPort:Byte);
  264. Begin                                   { Purges the OutPut Buffer   }
  265.   R.Ah := $09;
  266.   R.Dx := ComPort - 1;
  267.   Intr ($14,R)
  268. End;
  269.  
  270. Procedure Fossil_Nuke_Input (ComPort:Byte);
  271. Begin                                   { Purges the Input Buffer    }
  272.   R.Ah := $0A;
  273.   R.Dx := ComPort - 1;
  274.   Intr ($14,R)
  275. End;
  276.  
  277. Function NoWait_Send (K:Char):Boolean;
  278. Begin
  279.   R.Ah := $0B;
  280.   R.Al := Ord(K);
  281.   R.Dx := FosPort;
  282.   Intr ($14,R);
  283.   NoWait_Send := Boolean(R.Ax)
  284. End;
  285.  
  286. Function Fossil_Peek:Char;              { Checks out what the Next   }
  287. Begin                                   { Character is in FOSPORT    }
  288.   R.Ah := $0C;                          { Without Taking it out of   }
  289.   R.Dx := FosPort;                      { the Bufffer                }
  290.   Intr ($14,R);
  291.   Fossil_Peek := Chr(R.Al)
  292. End;
  293.  
  294. Function Fossil_GetChar:Char;         { Gets Character from Input Buffer }
  295. Begin                                 { $FFFF if none: HIGH Byte is Scan }
  296.   R.Ah := $0D;                        { code                             }
  297.   R.Dx := FosPort;
  298.   Intr ($14,R);
  299.   Fossil_GetChar := Chr(R.Al)
  300. End;
  301.  
  302. Function Fossil_Wait:Char;            { Waits until a Character has been }
  303. Begin                                 { Receieved                        }
  304.   R.Ah := $0E;
  305.   R.Dx := FosPort;
  306.   Intr ($14,R);
  307.   Fossil_Wait := Chr(R.Al)
  308. End;
  309.  
  310. Procedure Fossil_FLOW (State:Byte);   { Sets Flow Control    }
  311. Begin                                 { 0 = Disabled         }
  312.   R.Ah := $0F;                        { Bit 0 & 3 = XON/XOFF } { Chars     }
  313.   R.Al := State;                      { Bit 1     = CTS/RTS  } { Signals * }
  314.   R.Dx := FosPort;                    { Call using the defined Constants   }
  315.   Intr ($14,R)
  316. End;
  317.  
  318. Procedure Set_CtrlC (ComPort,State:Byte);
  319. Begin
  320.   R.Ah := $10;
  321.   R.Al := State;
  322.   R.Dx := ComPort - 1;
  323.   Intr ($14,R)
  324. End;
  325.  
  326. Function CtrlC_Check (ComPort:Byte):Boolean;
  327. Begin
  328.   R.Ah := $10;
  329.   R.Al := 2;
  330.   R.Dx := ComPort - 1;
  331.   Intr ($14,R);
  332.   CtrlC_Check := Boolean(R.Ax)
  333. End;
  334.  
  335. Procedure Fossil_GotoXY (X,Y:Byte);
  336. Begin
  337.   R.Ah := $11;
  338.   R.Dh := Y - 1;
  339.   R.Dl := X - 1;
  340.   Intr ($14,R)
  341. End;
  342.  
  343. Procedure Fossil_Position (Var X,Y:Byte);
  344. Begin
  345.   R.Ah := $12;
  346.   Intr ($14,R);
  347.   X := R.Dl + 1;
  348.   Y := R.Dh + 1
  349. End;
  350.  
  351. Function Fossil_WhereX:Byte;
  352. Begin
  353.   R.Ah := $12;
  354.   Intr ($14,R);
  355.   Fossil_WhereX := R.Dl + 1
  356. End;
  357.  
  358. Function Fossil_WhereY:Byte;
  359. Begin
  360.   R.Ah := $12;
  361.   Intr ($14,R);
  362.   Fossil_WhereY := R.Dh + 1
  363. End;
  364.  
  365. Procedure ANSI_Write (K:Char);        { Projects Character to Screen   }
  366. Begin                                 { through ANSI.SYS               }
  367.   R.Ah := $13;
  368.   R.Al := Ord(K);
  369.   R.Dx := FosPort;
  370.   Intr ($14,R)
  371. End;
  372.  
  373. Procedure WatchDog (Status:Boolean);  { Sets WatchDOG = ON/OFF        }
  374. Begin                                 { If ON then Reboots on Carrier }
  375.   R.Ah := $14;                        { Loss!                         }
  376.   R.Al := Byte(Status);
  377.   R.Dx := FosPort;
  378.   Intr ($14,R)
  379. End;
  380.  
  381. Procedure BIOS_Write (K:Char);        { Writes a Character to the     }
  382. Begin                                 { Screen Using BIOS Screen Write}
  383.   R.Ah := $15;
  384.   R.Al := Ord(K);
  385.   R.Dx := FosPort;
  386.   Intr ($14,R)
  387. End;
  388.  
  389. Function Add_Fossil_Proc (Var P):Boolean;
  390. Begin
  391.   R.Ah := $16;
  392.   R.Al := $01;
  393.   R.ES := Seg (P);
  394.   R.DX := Ofs (P);
  395.   Intr ($14,R);
  396.   Add_Fossil_Proc := R.Ax = 0
  397. End;
  398.  
  399. Function Delete_Fossil_Proc (Var P):Boolean;
  400. Begin
  401.   R.Ah := $16;
  402.   R.Al := $00;
  403.   R.ES := Seg (P);
  404.   R.DX := Ofs (P);
  405.   Intr ($14,R);
  406.   Delete_Fossil_Proc := R.Ax = 0
  407. End;
  408.  
  409. Procedure ColdBoot;                   { Does a Cold Reboot            }
  410. Begin
  411.   R.Ah := $17;
  412.   R.Al := $00;
  413.   Intr ($14,R)
  414. End;
  415.  
  416. Procedure WarmBoot;                   { Does a Warm Reboot            }
  417. Begin
  418.   R.Ah := $17;
  419.   R.Al := $01;
  420.   Intr ($14,R)
  421. End;
  422.  
  423. Function Fossil_BlockRead (Bytes:Word; Var Buffer):Integer;
  424. Begin                                 { BUFFER is an Array, and BYTES is  }
  425.   R.Ah := $18;                        { the size of the Array.            }
  426.   R.Dx := FosPort;                    { It Returns the number of recieved }
  427.   R.Cx := Bytes;                      { Characters.                       }
  428.   R.ES := Seg (Buffer);
  429.   R.DI := Ofs (Buffer);
  430.   Intr ($14,R);
  431.   Fossil_BlockRead := R.Ax
  432. End;
  433.  
  434. Function Fossil_BlockWrite (Bytes:Word; Var Buffer):Integer;
  435. Begin                                 { Writes an Array of BYTES Chars    }
  436.   R.Ah := $19;                        { to the FOSPORT from BUFFER        }
  437.   R.Dx := FosPort;                    { Returns the number of characters  }
  438.   R.Cx := Bytes;                      { sent.                             }
  439.   R.ES := Seg (Buffer);
  440.   R.DI := Ofs (Buffer);
  441.   Intr ($14,R);
  442.   Fossil_BlockWrite := R.Ax
  443. End;
  444. *)
  445.  
  446. Function Fossil_Descrip (ComPort:Byte):String;
  447. Var Cnt:Integer;                      { Returns the Communications FOSSIL }
  448.     Fos_Arry:Fossil_Struct;           { Driver Utilizing the COMPORT      }
  449.     First,Second:Word;                { Communications Port               }
  450.     Kar:Char;                         { Returns the FOSSIL Driver         }
  451.     S:String;                         { Description.                      }
  452. Begin
  453.   R.Ah := $1B;
  454.   R.Dx := ComPort - 1;
  455.   R.ES := Seg (Fos_Arry);
  456.   R.DI := Ofs (Fos_Arry);
  457.   R.CX := SizeOf (Fos_Arry);
  458.   Intr ($14,R);
  459.   First  := Fos_Arry.FOS_ID[2];
  460.   Second := Fos_Arry.FOS_ID[1];
  461.   S   := '';
  462.   Kar := #26;
  463.   While Kar <> #0 Do Begin
  464.     Kar:=Chr (Mem[First:Second]);
  465.     S := S + Kar;
  466.     Second:=Second + 1
  467.   End;
  468.   Fossil_Descrip:=S
  469. End;
  470.  
  471. Begin
  472. End.